package com.xidian.zhiancloud.controller.equipFacility.statistics;

import com.xidian.zhiancloud.controller.base.BaseController;
import com.xidian.zhiancloud.dto.ResultDTO;
import com.xidian.zhiancloud.enums.GeneralResponseEnums;
import com.xidian.zhiancloud.qo.equipFacility.StatisticQO;
import com.xidian.zhiancloud.service.equipFacility.EquipStatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 设备统计
 *
 * @Author: Summerless
 * @Date: 2021/4/2 22:46
 */
@RestController
@RequestMapping("/EquipStatistics")
public class EquipStatisticsController extends BaseController {

    @Autowired
    private EquipStatisticsService equipStatisticsService;

    /**
     * 获取区域/位置统计
     * @param qo 统计信息查询对象
     * @return 位置统计
     */
    @GetMapping("/getPositionStatistics")
    public ResultDTO<Map<Long, Map>> getPositionStatistics(StatisticQO qo){
        qo.setCompanyId(getSessionUserCompanyId());
        return ResultDTO.successOf(equipStatisticsService.getPositionStatistics(qo), GeneralResponseEnums.SUCCESS);
    }

    /**
     * 设备数量统计信息
     * @param qo 统计信息查询对象
     * @return 设备数量统计信息
     */
    @GetMapping("/getEquipQuantity")
    public ResultDTO<Map<String,Integer>> getEquipQuantity(StatisticQO qo){
        qo.setCompanyId(getSessionUserCompanyId());
        return ResultDTO.successOf(equipStatisticsService.getEquipQuantity(qo), GeneralResponseEnums.SUCCESS);
    }

    /**
     * 设备状态统计
     * @param qo 统计信息查询对象
     * @return 设备状态统计
     */
    @GetMapping("/getEquipStatusInfo")
    public ResultDTO<Map> getEquipStatusInfo(StatisticQO qo){
        qo.setCompanyId(getSessionUserCompanyId());
        return ResultDTO.successOf(equipStatisticsService.getEquipStatusInfo(qo), GeneralResponseEnums.SUCCESS);
    }

    /**
     * 管辖部门统计
     * @param qo 统计信息查询对象
     * @return 管辖部门统计
     */
    @GetMapping("/getEquipDepartmentInfo")
    public ResultDTO<Map> getEquipDepartmentInfo(StatisticQO qo){
        qo.setCompanyId(getSessionUserCompanyId());
        return ResultDTO.successOf(equipStatisticsService.getEquipDepartmentInfo(qo), GeneralResponseEnums.SUCCESS);
    }

    /**
     * 设备类型统计
     * @param qo 统计信息查询对象
     * @return 设备类型统计
     */
    @GetMapping("/getEquipTypeInfo")
    public ResultDTO<Map> getEquipTypeInfo(StatisticQO qo){
        qo.setCompanyId(getSessionUserCompanyId());
        return ResultDTO.successOf(equipStatisticsService.getEquipTypeInfo(qo), GeneralResponseEnums.SUCCESS);
    }



}
